﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace ServerVideoChat
{
	/// <summary>
	/// Interaction logic for Window_Main.xaml
	/// </summary>
	public partial class Window_Main : Window
	{
		public Window_Main()
		{
			this.InitializeComponent();
            DataContext = App.ViewModel;
            Loaded += (_1, _2) =>
            {
                //PeerResolver.Start();
                App.ViewModel.RunConferencService();
            };
            this.Closing += new System.ComponentModel.CancelEventHandler(Window_Main_Closing);
		}

        void Window_Main_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            try
            {
                App.ViewModel.CloseModel();

            }
            catch (Exception)
            {
                
            }
            //throw new NotImplementedException();
        }

        private void Window_KeyUp(object sender, System.Windows.Input.KeyEventArgs e)
        {
            switch (e.Key)
            {
                case Key.F1:
                    if (frmMain.Content is Page_ServerMain) return;
                    frmMain.NavigationService.Navigate(new Page_ServerMain());
                    break;
                case Key.F2:
                    if (frmMain.Content is Page_Settings) return;
                    frmMain.NavigationService.Navigate(new Page_Settings());
                    break;
                case Key.F5:
                    e.Handled = true;
                    return;
                    break;
            }
        }
	}
}